let form = document.querySelector('form')
let username = document.querySelector('.username')
let password = document.querySelector('.password')
let npassword = document.querySelector('.npassword')
let nickname = document.querySelector('.nickname')

form.addEventListener('submit',e =>{
    console.log(1);
    e=e||window.event

     try{
       e.preventDefault()
     }catch(err){
       e.returnValue=false
     }

     let name = username.value.trim()
     let pw = password.value.trim()
     let npw = npassword.value.trim()
     let nick = nickname.value.trim()

     if(!name||!pw||!npw||!nick)return alert('内容不能是空的')
     if(pw!==npw) return alert('两次密码不一致，请输入正确密码')
     window.localStorage.setItem('name',name)
     window.localStorage.setItem('password',pw)
     window.location.href='../views/login.html'
})